from rest_framework import serializers
from rest_framework.validators import UniqueValidator

from system.models import Department


class DepartmentSerializers(serializers.ModelSerializer):
    name = serializers.CharField(label='部门名称', max_length=10, validators=[UniqueValidator(queryset=Department.objects.all(),message='该部门已存在，无需重复添加')])
    class Meta:
        model = Department
        fields = '__all__'